package treeMap;

import java.util.Comparator;
import java.util.Map;

public class TreeMap {
    public static void main(String[] args) {
        //要求一：按照id的升序排序(默认)
        //要求二：根据id降序排序
        Map<Integer,String>map=new java.util.TreeMap<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
               return o2-o1;
            }
        });
        map.put(5,"ds");
        map.put(2,"xh");
        map.put(3,"tx");
        map.put(1,"wzxq");
        map.put(4,"ydsg");

        System.out.println(map);


    }
}
